package common;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;


public class ConfigEntity {
	
    public ConfigEntity() {
    	init();
    }
    
    public static boolean  debug = false;
    
    public static String   testDomainPrefix = ""; // 테스트 도메인 구분자
    
    public static String[] enableMainDomain = null; // 접근허용 URL

    public static String   sendEmail        = "";  // 시스템 발송메일 주소 
    
    public static void init() {
        Properties props = new Properties();  
        URL settingsUrl = Thread.currentThread().getContextClassLoader().getResource( "applicatoinConfig.properties" );
        
        // Load settings
        InputStream in = null;
        try {
            in = settingsUrl.openStream();
            props.load( in );
            
            testDomainPrefix = props.getProperty( "domain.testDomainPrefix" ).trim();
            enableMainDomain = (props.getProperty( "domain.enableMainDomain" ).trim()).split(",");

            sendEmail        = props.getProperty( "email.sendEmail" ).trim();
            
            if (debug) {
            	System.out.println( "## Config Entity Init values ##");
            	System.out.println( "domain.testDomainPrefix = " + testDomainPrefix);  	
            }
        } catch ( IOException e ) {
            System.out.println("## ERROR : applicatoinConfig.properties INIT FAILED!!" );
            
        } finally {
            try {
                in.close();
            } catch ( IOException e ) {}
        }        
    }

    public String getTestDomainPrefix() {
    	return this.testDomainPrefix;
    }

    public String getSendEmail() {
    	return this.sendEmail ;
    }
}
